package im.yisme.view.ui.util;

import im.yisme.R;
import im.yisme.view.ui.component.OnClickListener;

import java.util.ArrayList;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MusicListAdapter extends BaseAdapter {
	
	private ArrayList<Map<String, Object>> data1;
	private Context context;
	
	public MusicListAdapter(Context context, ArrayList<Map<String, Object>> data1) {
			this.context = context;
			this.data1 = data1;
	}
	
	public int getCount() {
		// TODO Auto-generated method stub
		return data1.size()+1;
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
        if(position == 0){
			
			convertView = LayoutInflater.from(context).inflate(
					R.layout.list_divider_music, null);
			
		}
		else if(position<data1.size()+1){
			TextView lyricsName = null;
			TextView duration = null;
			
				convertView = LayoutInflater.from(context).inflate(
						R.layout.musiclist_listitem_local, null);	
			
			
			
			lyricsName = (TextView) convertView.findViewById(R.id.textView_lyricsName);			
			duration = (TextView) convertView.findViewById(R.id.textView_duration);
			
			Map<String, Object> map=data1.get(position-1);
			
			lyricsName.setText((String)map.get("lyricsName"));
			duration.setText((String)map.get("duration"));
		}
	
		
		
		
		return convertView;
	}

}
